home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
tbbs
/
evnts102.zip
/
EVENTS.PRG
< prev
next >
Wrap
Text File
|
1996-04-19
|
44KB
|
1,676 lines
*****************************
* Events!
*
* A free calendar program to display upcoming events.
*
*
* 2-7-96 TF Added feature to put a * on days that have events
* scheduled in month view.
*
* Fixed a few minor glitches with the Today and Jump
* functions.
*
* Added the Next and Previous month functions to the help
* screen and reformated help screen a bit.
*
* Changed version number to 1.01 to reflect changes.
*
* 2-19-96 TF Fixed the JUMP command so that it is aware of different
* centuries.
*
* Made a few other cosmetic changes changing things like the
* color of the "Press any key..." prompt.
*
* 2-21-96 TF Added an entry parameter to allow the sysop to set the minimum
* user level required to Add or Edit events in the database. Only
* user with a priviledge level greater than or equal to the edLevel
* may Add new events. The only user that created the event may edit
* or delete it. Those with priv level > 200 can edit or delete
* any events. To use this parameter put a slash (/) followed by
* the privilege level after the title of the calendar.
* The Add, Edit and Delete commands will only be shown to users with
* the proper privilege level.
*
* If logged in with priv >= 200 you can now see the user ID
* of the user who created an event when viewing the events.
* Regular users do not see this info.
*
* If logged in with priv >= 200 you have access to the "Janitor"
* commands. Currently, the only available command allows you to
* "Cleanup" or pack the database file. The Janitor commands will
* only be shown to users with privilege level 200 and above.
*
* Added code to update the events database file if it was created
* by an older version of this program. Requires that the file
* DBUPDATE.TPG be in the same directory as the Events! program.
*
* If the last day of the month had an event scheduled it wasn't
* being reflected in with an asterisk in the month view. This
* has been fixed.
*
* 3-26-96 TF Integrated the historic events database back into the Events
* program. This is stored in the file HISTDB.DBF. All events in
* the database have the year set to 1900.
*
* 4-10-96 TF Added ability to delete events from a range of dates.
*
* Changed the version number in the Help box to 1.02 to
* reflect the changes that have been made.
*
set escape off
set deleted on
set century on
* First let's check the EVENTDB.DBF file to see if it needs updating
if file("eventdb.dbf")
use "eventdb.dbf"
if fcount() < 12
? "The EVENTDB.DBF file needs to be updated to work with this version"
? "of Events! The old databse file will be renamed EVENTDB.OLD and"
? "events from the old database will be copied to the new file."
? "When the conversion is done you will be returned back to the BBS."
? "The next time you access this menu item the Events! program will"
? "work normally."
?
? "Would you like to do the update now? (Y/N)"
key = upper(chr(inkey(0)))
if key = "Y"
dotbbs type 200 optdata homepath() + "dbupdate /q"
else
quit
endif
endif
endif
Public eDate, uQuit, lDate, drwScreen, calFile, eNum, rdb
Public calTitle, eText, monthView
* set procedure to evprocs
* Put the cursor in the top left of the screen
@0,0 say ""
* Global Stuff
ON = .T.
OFF = .F.
uQuit = .F.
* Name of the default event database files
calFile = "EVENTDB.DBF"
histFile = "HISTDB.DBF"
eNum = 1
maxLines = 18
eDate = date()
eYear = year(eDate)
eMonth = month(eDate)
eDay = day(eDate)
edLevel = 200
adminLevel = 200
*
* Read the OPTDATA and pull out the title info if available
* otherwise we just use the default title
*
offset = at(chr(38)+chr(38), optdata())
if offset <> 0
if "/" $ substr(optdata(), offset)
flag = at("/", substr(optdata(), offset))
calTitle = trim(substr(optdata(), offset + 3, (offset + flag) - (offset + 3) - 1))
tmp = trim(substr(optdata(), offset + flag))
if .not. isalpha(tmp)
edLevel = val(tmp)
endif
else
calTitle = trim(substr(optdata(), offset + 3))
endif
else
calTitle = "Events!"
endif
* If the event database file doesn't exist then create it
if .not. file(calFile)
do CreateDB
endif
do MonthView with calTitle
* Make sure we clean up our mess before leaving
use
close all
erase &rdb
erase &newstruc
quit
******************************
* Month View
Procedure MonthView
Parameters cTitle
do CalScreen
drwScreen = .T.
do while .T.
monthView = .T.
if drwScreen
set color to R/W
do Center with 1, cTitle
set color to B/W
do CalNum with eDate
do HiLite with eDate, ON
drwScreen = .F.
endif
key = inkey(0)
if key < 0
key = 0
endif
sel = upper(chr(key))
do case
*
* Previous Month
*
case sel = "P"
eMonth = eMonth - 1
if eMonth < 1
eMonth = 12
eYear = eYear - 1
endif
eDate = ctod(str(eMonth)+"/"+str(eDay)+"/"+str(eYear))
do CalScreen
drwScreen = .T.
*
* Next Month
*
case sel = "N"
eMonth = eMonth + 1
if eMonth > 12
eMonth = 1
eYear = eYear + 1
endif
eDate = ctod(str(eMonth)+"/"+str(eDay)+"/"+str(eYear))
do CalScreen
drwScreen = .T.
*
* Right cursor
*
case sel = chr(4)
do HiLite with eDate, OFF
eDate = eDate + 1
do HiLite with eDate, ON
if eMonth <> month(eDate)
eMonth = month(eDate)
drwScreen = .T.
endif
*
* Left Cursor
*
case sel = chr(19)
do HiLite with eDate, OFF
eDate = eDate - 1
do HiLite with eDate, ON
if eMonth <> month(eDate)
eMonth = month(eDate)
drwScreen = .T.
endif
*
* Cursor Up
*
case sel = chr(5)
do HiLite with eDate, OFF
eDate = eDate - 7
do HiLite with eDate, ON
if eMonth <> month(eDate)
eMonth = month(eDate)
drwScreen = .T.
endif
*
* Cursor Down
*
case sel = chr(24)
do HiLite with eDate, OFF
eDate = eDate + 7
do HiLite with eDate, ON
if eMonth <> month(eDate)
eMonth = month(eDate)
drwScreen = .T.
endif
*
* Quit - on Q or ESC
*
case sel = "Q" .or. key = 27
uQuit = .F.
set color to W/
@5,0 clear to 24,79
do UserQuit
if uQuit
return
else
do CalScreen
drwScreen = .T.
endif
*
* Help
*
case sel = "?"
do ShowHelp
do CalScreen
drwScreen = .T.
*
* Info
*
case sel = "I"
do ShowInfo
do CalScreen
drwScreen = .T.
*
* Select
*
case sel = chr(13)
do WeekView with cTitle
drwScreen = .T.
*
* Show History
*
case sel = "H"
set color to R/W
do WeekHdr with "On This day in History", eDate
set color to B/W
do DayLite with eDate, .T.
do HistView with eDate
do calScreen
drwScreen = .T.
*
* Jump to Date
*
case sel = "J"
do GetDate
do CalScreen
eMonth = month(eDate)
drwScreen = .T.
*
* Today - Jump to today's date
*
case sel = "T"
eDate = date()
do CalScreen
eMonth = month(eDate)
drwScreen = .T.
*
* Add Event
*
case sel = "A"
if upriv() >= edLevel
do DayHeader with "Add Event", eDate
do AddEvent
do CalScreen
drwScreen = .T.
endif
*
* Cleanup the Database
*
case sel = "C"
if upriv() > adminLevel
do DBPack
do CalScreen
drwScreen = .T.
endif
*
* Remove old events
*
case sel = "R"
if upriv() > adminLevel
do RemEvents
do CalScreen
drwScreen = .T.
endif
endcase
enddo
return
******************************
* Week View
Procedure WeekView
Parameters cTitle
monthView = .F.
eNum = 0
drwScreen = .T.
do while .T.
if drwScreen
set color to R/W
do WeekHdr with cTitle, eDate
set color to B/W
do DayLite with eDate, .T.
do ReadDayDB with eDate
do EventLite with eNum, ON
drwScreen = .F.
endif
key = inkey(0)
if key < 0
key = 0
endif
sel = upper(chr(key))
do case
*
* Right cursor - Move to next day
*
case sel = chr(4)
do DayLite with eDate, .F.
eDate = eDate + 1
eNum = 0
do DayLite with eDate, .T.
do ReadDayDB with eDate
do EventLite with eNum, ON
*
* Left Cursor - Move to previous day
*
case sel = chr(19)
do DayLite with eDate, .F.
eDate = eDate - 1
eNum = 0
do DayLite with eDate, .T.
do ReadDayDB with eDate
*
* Previous Month
*
case sel = "P"
eMonth = eMonth - 1
if eMonth < 1
eMonth = 12
eYear = eYear - 1
endif
eDate = ctod(str(eMonth)+"/"+str(eDay)+"/"+str(eYear))
drwScreen = .T.
*
* Next Month
*
case sel = "N"
eMonth = eMonth + 1
if eMonth > 12
eMonth = 1
eYear = eYear + 1
endif
eDate = ctod(str(eMonth)+"/"+str(eDay)+"/"+str(eYear))
drwScreen = .T.
*
* Cursor Up - Move to previous item in list of events
*
case sel = chr(5)
if eNum > 1
do EventLite with eNum, OFF
eNum = eNum - 1
do EventLite with eNum, ON
endif
*
* Cursor Down - Move to next item in list of events
*
case sel = chr(24)
if eNum > 0 .and. eNum <> reccount()
do EventLite with eNum, OFF
eNum = eNum +1
do EventLite with eNum, ON
endif
*
* Quit
*
case sel = "Q"
uQuit = .F.
set color to w/
@7,0 clear to 24,79
do UserQuit
if uQuit
return to master
else
drwScreen = .T.
endif
*
* Help
*
case sel = "?"
do ShowHelp
drwScreen = .T.
*
* Info
*
case sel = "I"
do ShowInfo
drwScreen = .T.
*
* Select
*
case sel = chr(13)
if eNum > 0
do EventView with eDate, eNum
drwScreen = .T.
endif
*
* History
*
case sel = "H"
do HistView with eDate
drwScreen = .T.
*
* Jump to Date
*
case sel = "J"
do GetDate
drwScreen = .T.
*
* Today - Jump to today's date
*
case sel = "T"
eDate = date()
drwScreen = .T.
*
* Add an Event
*
case sel = "A"
if upriv() >= edLevel
do DayHeader with "Add Event", eDate
do AddEvent
eNum = 0
drwScreen = .T.
endif
*
* Edit an Event
*
case sel = "E"
if eNum > 0 .and. upriv() >= edLevel
cNum = RNUM
use &calFile
go cNum
if upriv() >= adminLevel .or. (uname() = rtrim(EVUSER) .and. upriv() >= edLevel)
do DayHeader with "Edit Event", eDate
do EditEvent with cNum
eNum = 0
drwScreen = .T.
else
do NotAuth
drwScreen = .T.
endif
endif
*
* Delete an Event
*
case sel = "D"
if eNum > 0 .and. upriv() >= edLevel
cNum = RNUM
use &calFile
go cNum
if upriv() > adminLevel .or. (uname() = rtrim(EVUSER) .and. upriv() >= edLevel)
curRec = cNum
do Box3D with 8,12,13,68,0
set color to R/W
do Center with 9,"Delete Event"
set color to B/W
do center with 11,"Are you sure you want to delete this event? (Y/N)"
wait "" to key
if upper(key) = "Y"
use &calFile
go curRec
delete
use
endif
set color to w/
eNum = 0
drwScreen = .T.
else
do NotAuth
drwScreen = .T.
endif
endif
*
* Change to Month View on ESC
*
case key = 27
do CalScreen
drwScreen = .T.
return
*
* Cleanup the Database
*
case sel = "C"
if upriv() > adminLevel
do DBPack
drwScreen = .T.
endif
*
* Remove old events
*
case sel = "R"
if upriv() > adminLevel
do RemEvents
drwScreen = .T.
endif
endcase
enddo
return
**************************************************************
* Events! Procedures
********************************
Procedure HiLite
Parameters cDate, cState
*
* Change the highlight the given date.
*
Private cRow, cCol, cDay1
cCol = 6 + ((dow(cDate) - 1) * 10)
cDay1 = cDate - (day(cDate) - 1)
cRow = 6 + (int(((day(cDate)-1)+ (dow(cDay1)-1))/7) * 3)
if cState
set color to BG+/B
else
set color to B/W
endif
@cRow,cCol-1 say " " + ltrim(str(day(cDate))) + " "
return
********************************
Procedure DayLite
Parameters cDate, cState
*
* Change the highlight on the day in the WeekView.
*
Private cRow, cCol, dCols
cRow = 4
dCols = " 8162433445462"
cCol = val(substr(dCols,((dow(cDate)-1)*2+1),2))
if cState
set color to B/W
@2,20 clear to 2,60
do LongDate with cDate
@2,6 say lDate
set color to BG+/B
else
set color to B/W
endif
@cRow,cCol say cdow(cDate)
return
********************************
Procedure EventLite
Parameters cNum, cState
*
* Change the highlight on the event in the event list.
*
if cNum <> 0
go cNum
if cState
set color to N/W
else
set color to W+/
endif
@cNum + 6, 5 say rtrim(RTITLE)
endif
return
********************************
Procedure ReadDayDB
Parameters cDate
*
* Checks for and displays list of events scheduled of the given date.
*
Private theRec, theTitle, theRow, theNum
* Make temporary databases with filename based on user's line number.
* This database is used to hold the record numbers and titles of the
* events found in the main event database file.
* First we close all the databases that might be open
use
* Then we create our new list file
rdb = "rdb"+ULINE()+".DBF"
newlist = "elist"+ULINE()+".DBF"
if file(rdb)
erase &rdb
endif
create &newlist
use &newlist
append blank
replace field_name with "RNUM", field_type with "N", field_len with 6
append blank
replace field_name with "RTITLE", field_type with "C", field_len with 64
* Now create the database from the template
use
create &rdb from &newlist
erase &newlist
* Open the 2 databases in different work areas
select 1
use &rdb
select 2
* if the database file doesn't exist then create it
if .not. file(calFile)
do CreateDB
endif
use &calFile
* Now let's read some records from our database
set color to w/
@7,0 clear
@7,0 say ""
if eNum = 0
eNum = 1
endif
set filter to EVDATE = cDate
go top
if eof()
set color to W+/N
do Center with 8, "** No events currently scheduled for this date **"
eNum = 0
set color to W/
else
theRow = 6
do while .not. eof() .and. theRow < 25
theRow = theRow + 1
theRec = recno()
theTitle = EVTITLE
theUser = EVUSER
select 1
append blank
replace RNUM with theRec
replace RTITLE with theTitle
* Display the list item
set color to GR+/N
@theRow,2 say ltrim(str(recno())) + "."
set color to W+/N
@theRow,5 say theTitle
select 2
skip
enddo
endif
* Clean up our mess
set filter to
use
select 1
use
use &rdb
do EventLite with eNum, ON
set color to W/
return
********************************
Procedure HistView
Parameters cDate
*
* Displays list of historical events for the given date.
*
Private theRec, theTitle, theRow, theNum
if file(histFile)
use &histFile
else
set color to W+/N
do Center with 8, "** Sorry, the Historic Events database seems to be missing. **"
set color to R/N
do Center with 22," * * "
set color to BG+/N
do Center with 22,"Press any key to continue..."
set color to W/
wait ""
return
endif
* Now let's read some records from our database
set color to w/
@7,0 clear
@7,0 say ""
if eNum = 0
eNum = 1
endif
* All the events in the HISTDB.DBF file have the year set to 1900
* so we must set the search year to 1900 in order to find the items we want.
set filter to CALDATE = ctod(stuff(dtoc(cDate),7,4,"1900"))
go top
if eof()
set color to W+/N
do Center with 8, "** Nothing seems to have happened on this date in history **"
eNum = 0
set color to W/
else
theRow = 6
do while .not. eof() .and. theRow < 21
theRow = theRow + 1
theRec = recno()
theTitle = CALTEXT
* Display the list item
set color to W+/N
@theRow,0 say theTitle
skip
enddo
endif
* Clean up our mess
set filter to
use
set color to R/N
do Center with 22," * * "
set color to BG+/N
do Center with 22,"Press any key to continue..."
set color to W/
wait ""
set century on
set color to W/
return
********************************
Procedure CalNum
Parameters cDate
*
* Draws the month and year in the title area
* and fills the numbers in the calendar
*
Private tDate, tDay, cRow, cCol, cSqr, cnt
tDate = cDate
use &calFile
tDay = day(tDate)
tDate = tDate - (tDay - 1)
cMonYr = cmonth(tDate) + str(year(tDate))
set color to B/W
@2,6 clear to 2,70
do Center with 2, cMonYr
* Clear the calendar
cRow = 6
cSqr = 0
cnt = 1
do while cnt < 38
cCol = 6 + cSqr
@cRow,cCol say " "
if cCol = 66
cRow = cRow + 3
endif
cSqr = cSqr + 10
if cSqr > 60
cSqr = 0
endif
cnt = cnt + 1
enddo
* Now fill it in with the proper month
cRow = 6
do while .not. islastday(tDate)
cCol = 6 + ((dow(tDate) - 1) * 10)
* See if we have any events on this day. if so
* put a "*" in that date
set filter to EVDATE = tDate
go top
if eof()
@cRow,cCol say ltrim(str(day(tDate)))+ " "
else
@cRow,cCol say ltrim(str(day(tDate)))
set color to R/W
@cRow,cCol+3 say " *"
set color to B/W
endif
if cCol = 66
cRow = cRow + 3
endif
tDate = tDate + 1
enddo
* Last but not least we take care of the last day of the month
cCol = 6 + ((dow(tDate) - 1) * 10)
set filter to EVDATE = tDate
go top
if eof()
@cRow,cCol say ltrim(str(day(tDate)))+ " "
else
@cRow,cCol say ltrim(str(day(tDate)))
set color to R/W
@cRow,cCol+3 say " *"
set color to B/W
endif
return
********************************
Procedure EventView
Parameters cDate, cNum
*
* View the database item selected
*
Private recNum
use &rdb
go cNum
recNum = RNUM
use &calFile
go recNum
do DayHeader with "", cDate
set color to B/W
do Center with 4, rtrim(EVTITLE)
set color to GR+/N
@7,6 say "Date:"
@9,2 say "Location:"
@12,5 say "Desc.:"
@19,3 say "Contact:"
set color to W+/
@7,12 say dtoc(EVDATE)
@9,12 say EVLOC1
@10,12 say EVLOC2
@12,12 say EVDESC1
@13,12 say EVDESC2
@14,12 say EVDESC3
@15,12 say EVDESC4
@16,12 say EVDESC5
@17,12 say EVDESC6
@19,12 say EVCONT
* Only show who created the event to the administrators
if upriv() > adminLevel
set color to B/W
@20,0 say space(79)
@20,2 say "Login ID:"
set color to R/W
@20,12 say EVUSER
endif
set color to R/N
do Center with 21," * * "
set color to BG+/N
do Center with 21,"Press any key to continue..."
set color to W/
wait ""
use
return
********************************
Procedure DayHeader
Parameters dhTitle, cDate
* Put a box at the top of the screen with the current day and a title
* Used in the EventView and Edit modes
do LongDate with cDate
set color to w/
@0,0 clear
do Box3D with 0,1,6,79,0
set color to R/W
do Center with 1, dhTitle
set color to B/W
do Center with 2, lDate
set color to R/W
do Center with 3, replicate("─", 72)
set color to W/N
@8,0 clear to 24,79
return
********************************
Procedure WeekHdr
Parameters whTitle, cDate
*
set color to w/
@0,0 clear
do LongDate with cDate
do Box3D with 0,1,6,79,0
set color to R/W
do Center with 1, whTitle
set color to B/W
@2,6 say lDate
@2,66 say "<?> Help"
set color to R/W
do Center with 3, replicate("─", 72)
set color to W/N
@9,0 clear to 24,79
set color to B/W
@4,8 say "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
return
**********************************
Procedure LongDate
Parameters cDate
* Put the date in long form into the public string lDate
Private tDay, pday, post
pday = day(cDate)
* Put the postfix on the date
do case
case pday = 1 .or. pday = 21 .or. pday = 31
post = "st"
case pday = 2 .or. pday = 22
post = "nd"
case pday = 3 .or. pday = 23
post = "rd"
otherwise
post = "th"
endcase
lDate = cdow(cDate) + ", " + ltrim(cMonth(cDate)) + " " + ltrim(str(day(cDate))) + post + ", " + ltrim(str(year(cDate)))
return
********************************
Procedure GetDate
*
* Get a date from the user
*
do Box3D with 9,20,12,60,0
set color to B/W
@10,22 say "Jump to date: "
@10,40 get eDate picture "@D"
read
return
********************************
Procedure RemEvents
*
* Remove events from the database between the selected
* range of dates.
*
Private startDate, endDate
do Box3D with 7,10,17,70,0
startDate = date() - 30
endDate = date()
set intensity on
set color to R/W,w+/n
do Center with 8, "Remove Old Events"
set color to B/W,w+/n
@15,54 say "<ESC> Cancel"
set color to R/W,w+/n
@15,55 say "ESC"
set color to B/W,w+/n
@10,14 say "Start Date:" get startDate picture "@D"
@12,14 say " End Date:" get endDate picture "@D"
read
key = readkey()
do case
* Check for ESC key
case key = 12 .or. key = 268
return
* Check for valid date range
case startDate > endDate
@15,12 clear to 15,66
do center with 14,"Invalid date range!"
do center with 15," * Press any key to continue *"
wait ""
otherwise
@14,14 say "Really remove events between these dates? (Y/N)"
key = inkey(0)
if chr(key) = "Y" .or. chr(key) = "y"
* Delete events within the selected range of dates
@14,12 clear to 15,66
do center with 14, "Deleting events. Please wait..."
use &calFile
set filter to
go top
do while .not. EOF()
if EVDATE >= startDate .and. EVDATE <= endDate
delete
endif
skip
enddo
endif
endcase
use
return
****************************
Procedure ShowHelp
set color to W/N
if monthView
@5,0 clear to 24,79
else
@7,0 clear to 24,79
endif
do Box3D with 7,8,21,72,0
set color to R/W
do Center with 8, "Events! v1.02"
set color to B/W
do Center with 9, "By Tony Fardella"
@11,12 say "Cursor Keys - Move Enter - Select ESC - Back/Quit"
@12,12 say "J - Jump to Date T - Today Q - Quit"
@13,12 say "N - Next Month P - Prev Month H - History"
@14,12 say "I - Information"
* Only show these commands to users with the proper privilege level.
if upriv() >= edLevel
@15,12 say "A - Add Event E - Edit Event D - Delete Event"
endif
* Only show these commands to users with privilege level >= adminLevel
if upriv() >= adminLevel
set color to GR+/W
do center with 16,"Janitor's Closet"
set color to W+/W
@17,12 say "C - Clean Database R - Remove Events"
endif
set color to R/W
do Center with 19, "Press any key to continue"
wait ""
set color to w/
return
****************************
Procedure ShowInfo
set color to W/N
if monthView
@5,0 clear to 24,79
else
@7,0 clear to 24,79
endif
* do Box3D with 7,2,21,78,0
set color to BG+/N
do Center with 7, "Events! v1.02"
do Center with 9, "by Tony Fardella (tonyf@crl.com)"
set color to R/N
do Center with 8, "──────────────────────────────────────────────────────────────────"
set color to W/N
do Center with 11, "Events! allows you to post information on events or activities for others to"
do Center with 12, "to view. An event may be listed for any day of the year. Each listing"
do Center with 13, "includes a title, date, location, a description and contact information for"
do Center with 14, "the event. Days with scheduled events will have an asterisk (*) next to them"
do Center with 15, "in the monthly calendar view. You may add, edit, and delete events in the"
do Center with 16, "Events! database. You can jump to any date by pressing [J] and return to the"
do Center with 17, "current date by pressing [T]. A listing of historical events for any date may"
do Center with 18, "be accessed by pressing [H]."
do Center with 20, "* Have Fun! *"
set color to W+/N
do Center with 22, "* Press any key to continue *"
wait ""
set color to w/
return
*********************************
* Add Event
*
Procedure AddEvent
Private ctitle, cdate, cloc1, cloc2, cdes1, cdes2, cdes3, cdes4, cdes5, cdes6, ccont
set century on
clear gets
ctitle = space(60)
cloc1 = space(60)
cloc2 = space(60)
cdes1 = space(60)
cdes2 = space(60)
cdes3 = space(60)
cdes4 = space(60)
cdes5 = space(60)
cdes6 = space(60)
ccont = space(60)
cdate = eDate
@7,0 clear
* set delimiters to "::"
set delimiters on
set intensity on
do while .T.
set color to B/W
@4,4 clear to 4,76
@4,4 say "[ESC] Menu"
set color to R/W
@4,5 say "ESC"
set color to bg/n,w+/n
@7,5 say "Title" get ctitle
@9,6 say "Date" get cdate picture "@D"
@11,2 say "Location"
@11,11 get cloc1
@12,11 get cloc2
@14,6 say "Info"
@14,11 get cdes1
@15,11 get cdes2
@16,11 get cdes3
@17,11 get cdes4
@18,11 get cdes5
@19,11 get cdes6
@21,3 say "Contact" get ccont
read
set color to R/W
@4,4 clear to 4,76
do while .T.
set color to B/W
@4,4 say "[E]dit"
@4,12 say "[S]ave"
@4,64 say "[ESC] Cancel"
set color to R/W
@4,5 say "E"
@4,13 say "S"
@4,65 say "ESC"
@4,79 say ""
key = inkey(0)
if key < 0
key = 0
endif
sel = upper(chr(key))
do case
case sel = "S"
*
* if the database file doesn't exist then create it
*
if .not. file(calFile)
do CreateDB
endif
*
* Write the new event to the database
*
use &calFile
append blank
replace EVTITLE with ctitle
replace EVDATE with cdate
replace EVLOC1 with cloc1
replace EVLOC2 with cloc2
replace EVDESC1 with cdes1
replace EVDESC2 with cdes2
replace EVDESC3 with cdes3
replace EVDESC4 with cdes4
replace EVDESC5 with cdes5
replace EVDESC6 with cdes6
replace EVCONT with ccont
replace EVUSER with uname()
use
eNum = 0
do ReadDayDB with eDate
return
case sel = chr(27) && ESC
return
case sel = "E" && Edit
exit
endcase
enddo
enddo
set color to W/
return
*********************************
* Edit Event
*
Procedure EditEvent
Parameter cNum
Private ctitle, cdate, cloc1, cloc2, cdes1, cdes2, cdes3, cdes4, cdes5, cdes6, ccont
clear gets
use &calFile
go cNum
ctitle = EVTITLE
cdate = EVDATE
cloc1 = EVLOC1
cloc2 = EVLOC2
cdes1 = EVDESC1
cdes2 = EVDESC2
cdes3 = EVDESC3
cdes4 = EVDESC4
cdes5 = EVDESC5
cdes6 = EVDESC6
ccont = EVCONT
@7,0 clear
* set delimiters to "::"
set delimiters on
set intensity on
do while .T.
set color to B/W
@4,4 clear to 4,76
@4,4 say "[ESC] Menu"
set color to R/W
@4,5 say "ESC"
set color to bg/n,w+/n
@7,5 say "Title" get ctitle
@9,6 say "Date" get cdate picture "@D"
@11,2 say "Location"
@11,11 get cloc1
@12,11 get cloc2
@14,6 say "Info"
@14,11 get cdes1
@15,11 get cdes2
@16,11 get cdes3
@17,11 get cdes4
@18,11 get cdes5
@19,11 get cdes6
@21,3 say "Contact" get ccont
read
set color to R/W
@4,4 clear to 4,76
do while .T.
set color to B/W
@4,4 say "[E]dit"
@4,12 say "[S]ave"
@4,64 say "[ESC] Cancel"
set color to R/W
@4,5 say "E"
@4,13 say "S"
@4,65 say "ESC"
@4,79 say ""
key = inkey(0)
if key < 0
key = 0
endif
sel = upper(chr(key))
do case
case sel = "S"
*
* Write the event to the database
*
replace EVTITLE with ctitle
replace EVDATE with cdate
replace EVLOC1 with cloc1
replace EVLOC2 with cloc2
replace EVDESC1 with cdes1
replace EVDESC2 with cdes2
replace EVDESC3 with cdes3
replace EVDESC4 with cdes4
replace EVDESC5 with cdes5
replace EVDESC6 with cdes6
replace EVCONT with ccont
replace EVUSER with uname()
use
eNum = 0
do ReadDayDB with eDate
return
case sel = chr(27) && ESC
return
case sel = "E"
exit
endcase
enddo
enddo
set color to W/
return
***************************
Procedure CreateDB
*
* if the database file doesn't exist then create it
*
if .not. file(calFile)
create newstruc
use newstruc
append blank
replace field_name with "EVTITLE", field_type with "C", field_len with 64
append blank
replace field_name with "EVDATE", field_type with "D", field_len with 8
append blank
replace field_name with "EVLOC1", field_type with "C", field_len with 64
append blank
replace field_name with "EVLOC2", field_type with "C", field_len with 64
append blank
replace field_name with "EVDESC1", field_type with "C", field_len with 64
append blank
replace field_name with "EVDESC2", field_type with "C", field_len with 64
append blank
replace field_name with "EVDESC3", field_type with "C", field_len with 64
append blank
replace field_name with "EVDESC4", field_type with "C", field_len with 64
append blank
replace field_name with "EVDESC5", field_type with "C", field_len with 64
append blank
replace field_name with "EVDESC6", field_type with "C", field_len with 64
append blank
replace field_name with "EVCONT", field_type with "C", field_len with 64
append blank
replace field_name with "EVUSER", field_type with "C", field_len with 32
use
create &calFile from newstruc
erase newstruc.dbf
endif
return
*******************************
Procedure NotAuth
*
* Bring up a dialog telling the user they can't
* edit or delete a record they didn't create
*
set color to W/N
do Box3D with 8,12,15,68,0
set color to R/W
do center with 9,"Sorry"
set color to B/W
do center with 11,"You can't edit or delete an event you didn't create"
do center with 13, "Press any key to continue"
wait "" to key
set color to w/
return
*******************************
Procedure UserQuit
*
* Bring up a dialog box asking if the user really wants to quit.
*
set color to W/N
do Box3D with 8,18,13,62,0
set color to R/W
do center with 9,"Quit?"
set color to B/W
do center with 11,"Are you sure you want to quit? (Y/N)"
wait "" to key
if upper(key) = "Y"
uQuit = .T.
endif
set color to w/
return
********************************
Procedure Center
Parameters nRow, cText
*
* Centers text string on the screen
*
* Input: nRow = screen row
* cText = text string
*
private nCol
nCol = Uwidth() - Len(cText)
nCol = Max(nCol,0)
nCol = nCol / 2
If Uansi()
@nRow,nCol say cText
else
? Replicate(" ",nCol) + cText
endif
return
***************************
Procedure Box3D
Parameters orgRow, orgCol, endRow, endCol, bStyle
Private nRow
*
* Create a "3D" box of the size passed by the input parameters
*
* Input: orgRow, orgCol = starting point
* endRow, endCol = ending point
* bStyle = Box Style 0 = recessed 1 = extruded
set intensity off
set color to N/W
@orgRow,orgCol say " "
if bStyle = 0
set color to N+/W
else
set color to W+/W
endif
@orgRow,orgCol+1 say "┌" + replicate("─",(endCol - orgCol) - 4)
if bStyle = 0
set color to W+/W
else
set color to N+/W
endif
@orgRow,endCol-2 say "┐ "
set color to N+/N
@orgRow,endCol say "▄"
nRow = orgRow + 1
do while nRow < endRow - 1
set color to N/W
@nRow,orgCol say " "
if bStyle = 0
set color to N+/W
else
set color to W+/W
endif
@nRow,orgCol+1 clear to nRow,endCol
@nRow,orgCol+1 say "│"
if bStyle = 0
set color to W+/W
else
set color to N+/W
endif
@nRow,endCol-2 say "│"
set color to N+/N
@nRow,endCol say "█"
nrow = nRow + 1
enddo
set color to N/W
@endRow-1,orgCol say " "
if bStyle = 0
set color to N+/W
else
set color to W+/W
endif
@endRow-1,orgCol+1 say "└"
if bStyle = 0
set color to W+/W
else
set color to N+/W
endif
@endRow-1,orgCol+2 say replicate("─",(endCol - orgCol) - 4) + "┘ "
set color to N+/N
@endRow-1,endCol say "█"
set color to N+/N
@endRow,orgCol say " " + replicate("▀",endCol - orgCol)
return
**************************
Procedure CalScreen
*
* Display Print the calendar template on the screen
? chr(27)+"[40m"+chr(27)+"[2J"+chr(27)+"[3C"+chr(27)+"[47m "+chr(27)+"[0;1;30;47m┌────────────────────────────────────────────────────────────────────"+chr(27)+"[37m┐ "+chr(27)+"[30;40m▄"
? chr(27)+"[2;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[3;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[4;1H "+chr(27)+"[47m │ "+chr(27)+"[0;31;47mSun Mon Tue Wed Thu Fri Sat "+chr(27)+"[1;37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[5;1H "+chr(27)+"[47m └"+chr(27)+"[37m────────────────────────────────────────────────────────────────────┘ "+chr(27)+"[30;40m█"
? chr(27)+"[6;1H "+chr(27)+"[47m ┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐ "+chr(27)+"[30;40m█"
? chr(27)+"[7;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[8;1H "+chr(27)+"[47m └"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘ "+chr(27)+"[30;40m█"
? chr(27)+"[9;1H "+chr(27)+"[47m ┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐ "+chr(27)+"[30;40m█"
? chr(27)+"[10;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[11;1H "+chr(27)+"[47m └"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘ "+chr(27)+"[30;40m█"
? chr(27)+"[12;1H "+chr(27)+"[47m ┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐ "+chr(27)+"[30;40m█"
? chr(27)+"[13;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[14;1H "+chr(27)+"[47m └"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘ "+chr(27)+"[30;40m█"
? chr(27)+"[15;1H "+chr(27)+"[47m ┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐ "+chr(27)+"[30;40m█"
? chr(27)+"[16;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[17;1H "+chr(27)+"[47m └"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘ "+chr(27)+"[30;40m█"
? chr(27)+"[18;1H "+chr(27)+"[47m ┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐ "+chr(27)+"[30;40m█"
? chr(27)+"[19;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[20;1H "+chr(27)+"[47m └"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[s"
? chr(27)+"[u"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘ "+chr(27)+"[30;40m█"
? chr(27)+"[21;1H "+chr(27)+"[47m ┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────"+chr(27)+"[37m┐"+chr(27)+"[30m┌────────────────────────────────────────────────"+chr(27)+"[37m┐ "+chr(27)+"[30;40m█"
? chr(27)+"[22;1H "+chr(27)+"[47m │ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[37m│"+chr(27)+"[30m│ "+chr(27)+"[0;31;47mEvents! "+chr(27)+"[0;34;47m<Q>uit <?> Help "+chr(27)+"[1;37m│ "+chr(27)+"[30;40m█"
? chr(27)+"[23;1H "+chr(27)+"[47m └"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────┘"+chr(27)+"[30m└"+chr(27)+"[37m────────────────────────────────────────────────┘ "+chr(27)+"[30;40m█"
? chr(27)+"[24;1H ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀"+chr(27)+"[0m"+chr(27)+"[255D"
return
************************************
* Cleanup the database file
*
* This procedure removes all the deleted records from
* the database file. The most of this code is taken from an eSoft
* TDBS tech note.
*
Procedure DBPack
set color to W/N
do Box3D with 8,12,13,68,0
set color to R/W
do center with 9,"Cleanup Events Database"
set color to B/W
do center with 11,"Are you sure you want to clean the database? (Y/N)"
wait "" to key
if upper(key) = "Y"
ON ERROR DO FILEPROB
USE &calFile EXCLUSIVE
ON ERROR
COPY TO TEMP FOR .NOT. DELETED()
ZAP
APPEND FROM TEMP
ERASE TEMP.DBF
endif
set color to w/
return
********************************************
* Error handler in case USE EXCLUSIVE fails
*
PROCEDURE FILEPROB
set color to W/N
do Box3D with 8,12,13,68,0
set color to R/W
do center with 9,"Sorry"
set color to B/W
do center with 11,"The database cannot be cleaned at this time."
wait ""
return